package ee.propaganda.gparrot.client.view;


import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.VerticalPanel;
import ee.propaganda.gparrot.client.model.ServiceInfo.ServiceType;

class MainPanel extends Composite{
	private List<ServicePanel> servicePanels;
	private VerticalPanel bodyPanel;
	
	public MainPanel(){
		//create body panel
		bodyPanel = new VerticalPanel();
		this.initWidget(bodyPanel);
	}

	ServicePanel getServicePanel(ServiceType st){
		ServicePanel sp = null;
		
		for (ServicePanel servicePanel : servicePanels) {
			if(servicePanel.getServiceType() == st) 
				sp = servicePanel;
		}
		return sp;		
	}
	
	void setData(HashMap<ServiceType, Boolean> serviceData){
		//create service panel(s) for body
		servicePanels = new ArrayList<ServicePanel>();
		for (ServiceType serviceType : ServiceType.values()) {
			System.out.println(serviceType + " : " + serviceData.get(serviceType).booleanValue());
			ServicePanel sp = new ServicePanel(serviceType, serviceData.get(serviceType).booleanValue());
			servicePanels.add(sp);
			//add service panel to body
			bodyPanel.add(sp);
		}
		
	}
}
